export default {
    data() {
        return {
        	ruleForm: {
	            notice:'',
	            radio:"1",
	        },
        };
    },
    //进入页面加载
    mounted: function () {
        var that = this;
        //在缓存中获取值
        that.user_name = sessionStorage.getItem("user_name");
        that.user_id = sessionStorage.getItem("user_id");
        that.token = sessionStorage.getItem("access-token");
        if ((!that.token) || (!that.user_id) || (!that.user_name)) {
            that.$router.push('/login');
        }
        if(that.$route.query.role_id) {
            that.role_id = that.$route.query.role_id;
            that.detail();
        }

        // 获取门店列表
        that.get_store_list();
    },

    methods: {
        //发送请求
        addClass: function () {
            var formData = {};
            formData.token = that.token;
            formData.type = that.type;
            //请求登陆接口
            that.$http.post(that.adminApi.api_url + "/Manager/add",formData, {emulateJSON: true}).then(
                function (res) {
                    // 处理成功的结果
                    that.$message({
                        type: 'success',
                        message: `操作提示: ${ '添加成功' }`
                    });
                    that.$router.push('/set_up/staff');
                }, function () {
                    // 处理失败的结果
                    that.$message({
                        type: 'error',
                        message: `操作提示: ${ '处理异常' }`
                    });
                });
        },

        //修改
        editClass:function () {
            var that = this;
            //请求登陆接口
            that.$http.post(that.adminApi.api_url + "/Manager/edit", {
                token: that.token,
                id:that.role_id,
            }, {emulateJSON: true}).then(
                function (res) {
                    // 处理成功的结果
                    that.$message({
                        type: 'success',
                        message: `操作提示: ${ '添加成功' }`
                    });
                    that.$router.push('/set_up/staff');
                }, function (res) {
                    // 处理失败的结果
                    that.$message({
                        type: 'error',
                        message: `操作提示: ${ res.body.msg }`
                    });
                });
        },
    }
}